import os
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
# 打开Chrome浏览器
driver = webdriver.Chrome()
driver.maximize_window()
# 打开链接
link = 'file:///' + os.path.abspath('注册实例.html')
driver.get(link)
#定位alter按钮并点击
alter = driver.find_element(By.ID,'alert')
alter.click()
time.sleep(2)
#点击弹窗内的确定
alter1 = driver.switch_to.alert
alter1.accept()